package com.zoe.onelink.guide.provider.attr;

import com.vladsch.flexmark.ast.FencedCodeBlock;
import com.vladsch.flexmark.ast.Heading;
import com.vladsch.flexmark.html.AttributeProvider;
import com.vladsch.flexmark.html.renderer.AttributablePart;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.html.MutableAttributes;
import org.jetbrains.annotations.NotNull;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2022</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2022-11-29
 */
public class HtmlAttributeProvider implements AttributeProvider {
    @Override
    public void setAttributes(@NotNull Node node, @NotNull AttributablePart attributablePart, @NotNull MutableAttributes mutableAttributes) {
        // 给pre标签和h标签添加样式
        if ((node instanceof Heading || node instanceof FencedCodeBlock) && attributablePart == AttributablePart.NODE) {
            mutableAttributes.addValue("style", "margin:0");
        }
    }
}
